package com.alibaba.serverless.domain;

import com.alibaba.serverless.common.domain.BaseEntity;
import com.alibaba.serverless.common.exception.BizException;
import com.alibaba.serverless.common.util.DateUtils;
import com.alibaba.serverless.common.util.StringUtils;
import com.alibaba.serverless.service.handle.v20201108.config.SmtpSendType;

import java.util.Date;

/**
 * 接收的参数
 * @author mac_zyj
 */
public class ReceiveParams extends BaseEntity {
    /**发送地址*/
    private String toAddress;
    /**事务编号*/
    private String smtpNo;
    /**校验码*/
    private String checkCode;
    /**使用者名称*/
    private String operateName;
    /**模块*/
    private String model;
    /**Ip地址*/
    private String ipAddress;
    private String fileKey;
    private String fileLocation;
    /**类型*/
    private int type;
    /**当前时间*/
    private Date currentTime;

    public ReceiveParams( ) {
       currentTime = DateUtils.getNowDate();
    }

    public void checkReceiveParams(){
        if (StringUtils.isEmpty(toAddress)){
            throw new BizException("发送地址不能为空");
        }
        if (StringUtils.isEmpty(model)){
            throw new BizException("模块名称不能为空");
        }
    }
    public String getConditionName(){
        checkReceiveParams();
        //类型名称
        String typeName= SmtpSendType.getTypeNameByType(type);
        if (StringUtils.isEmpty(typeName)){
            throw new BizException("请确认邮件类型是否正确!");
        }
        return model+typeName;
    }

    public String getFileLocation() {
        return fileLocation;
    }

    public void setFileLocation(String fileLocation) {
        this.fileLocation = fileLocation;
    }

    public void setCheckCode(String checkCode) {
        this.checkCode = checkCode;
    }

    public String getFileKey() {
        return fileKey;
    }

    public void setFileKey(String fileKey) {
        this.fileKey = fileKey;
    }

    public void setSmtpNo(String smtpNo) {
        this.smtpNo = smtpNo;
    }

    public String getSmtpNo() {
        return smtpNo;
    }

    public String getCheckCode() {
        return checkCode;
    }

    public Date getCurrentTime() {
        return currentTime;
    }

    public void setCurrentTime(Date currentTime) {
        this.currentTime = currentTime;
    }

    public String getOperateName() {
        return operateName;
    }

    public void setOperateName(String operateName) {
        this.operateName = operateName;
    }

    public String getToAddress() {
        return toAddress;
    }

    public void setToAddress(String toAddress) {
        this.toAddress = toAddress;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

}
